# 1129 还没完成。。。。。。。
from typing import List


class Solution:
    def shortestAlternatingPaths(self, n: int, redEdges: List[List[int]], blueEdges: List[List[int]]) -> List[int]:
        res = [-1]*n
        res[0] = 0

        red_set = set()
        blue_set = set()

        for inner_list in redEdges:
            red_set.add((inner_list[0], inner_list[1]))

        for inner_list in blueEdges:
            blue_set.add((inner_list[0], inner_list[1]))

        for m in range(1, n):
            color_flag = ''
            step = 0
            for i in range(m):
                if ((i-1, i) in red_set) and ((i-1, i) in blue_set):
                    color_flag = 'b' if color_flag == 'r' else 'r'
                elif (i-1, i) in red_set:
                    if color_flag == 'r':
                        step = -1
                        break
                    else:
                        color_flag = 'r'
                elif (i-1, i) in blue_set:
                    if color_flag == 'b':
                        step = -1
                        break
                    else:
                        color_flag = 'b'

                step += 1
            res[m] = step

        return res


print(Solution().shortestAlternatingPaths(3, [[0, 1], [1, 2]], []))
